#include<bits/stdc++.h>
using namespace std;
const int WZ=8;
struct nd{
	int aa;
	int bb;
	int cc;
	int dd;
	int ee;
};
nd server[1010],client[1010];
string x,y;
int a=0,b=0,c=0,d=0,e=0;
int n,ser=0,sli=0;
bool st(){
	int oop=WZ;
	while(x[oop]!='.'||oop<=WZ+3){
		a=a*10+x[oop]-'0';
		oop++;
	}
	if(a>255||a<0||x[oop]!='.') return false;
	oop++;
	while(x[oop]!='.'||oop<=WZ+7){
		b=b*10+x[oop]-'0';
		oop++;
	}
	if(b>255||b<0||x[oop]!='.') return false;
	oop++;
	while(x[oop]!='.'||oop<=WZ+11){
		c=c*10+x[oop]-'0';
		oop++;
	}
	if(c>255||c<0||x[oop]!='.') return false;
	oop++;
	while(x[oop]!=':'||oop<=WZ+15){
		d=d*10+x[oop]-'0';
		oop++;
	}
	if(d>255||d<0||x[oop]!=':') return false;
	oop++;
	while(oop<=x.size()){
		e=e*10+x[oop]-'0';
	}
	if(e>65535||e<0) return false;
}
bool sv(){
	for(int i=1;i<=ser;i++){
		if(server[i].aa==a&&server[i].bb==b&&server[i].dd==d){
			if(server[i].cc==c&&server[i].ee==e)
				return false;
		}
	}
	ser++;
	server[ser].aa=a;
	server[ser].bb=b;
	server[ser].cc=c;
	server[ser].dd=d;
	server[ser].ee=e;
	return true;
}
int main()
{
	freopen("network.in","r",stdin);
	freopen("network.out","w",stdout);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		getline(cin,x);
		if(x[0]=='S'){
			if(st()){
				if(sv()){
					cout<<"OK"<<endl;
				}else cout<<"FAIL"<<endl;
			}else cout<<"ERR"<<endl;
		}else{
			if(st()){
				
			}else cout<<"ERR"<<endl; 
		}
	}
	return 0;
}
